package cn.tedu.file;
/**
 * @Author 金帮嘉诚  @Date 2021-06-17 周四 19:56
 */
/*本类用于测试字符输出流*/

import java.io.*;

/**
 知识点：
 Writer()
 FileWriter()
 BufferedWriter()
 */
public class TestOut2 {
    public static void main(String[] args) {
        method1();
        method2();
    }

    private static void method2() {
        Writer out=null;

        try {
        out=new BufferedWriter(new FileWriter(new File("D:\\ready\\9.txt"),true));
            out=new BufferedWriter(new FileWriter("D:\\ready\\9.txt",true));

            out.write("hello");
            out.write("hello");
            out.write("hello");
            out.write("hello~~~~~");
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                out.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    private static void method1() {
        Writer out=null;

        try {
//        out=new FileWriter(new File("D:\\ready\\9.txt"),true);
            out=new FileWriter("D:\\ready\\9.txt",true);

            out.write("jbjc");
            out.write("jbjc");
            out.write("jbjc");
            out.write("jbjc~~~~~");
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                out.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
